package com.woniuxy.service.impl;

import com.woniuxy.mapper.PermissionMapper;
import com.woniuxy.pojo.Permission;
import com.woniuxy.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;
    @Override
    public List<Permission> findAllPermissions() {
        return this.permissionMapper.selectAllPermissions();
    }

    @Override
    public List<Integer> selectPerIds(int rid) {
        List<Permission> permissionList=this.permissionMapper.selectPermissionsByRid(rid);
        List<Integer> pids=new ArrayList<>();
        for(Permission permission:permissionList){
            pids.add(permission.getId());
        }
        return pids;
    }

}
